< previous page page_613 next page >

Page 613
    RayTraceable_FindT = -1
    Exit Function
End If

' Find the unit normal at this point.
GetUnitNormal Nx, Ny, Nz 

' Compute the plane's parameters. 
A = Nx 
B = Ny 
C = Nz 
D = -(Nx * Point1.Trans(1) + _ 
      Ny * Point1.Trans(2) + _ 
      Nz * Point1.Trans(3)) 

' If the denominator = 0, the ray is parallel 
' to the plane so there's no intersection. 
denom = A * Vx + B * Vy + C * Vz 
If denom = 0 Then 
    RayTraceable_FindT = -1 
    Exit Function 
End If

' Solve for t.
t = -(A * px + B * py + C * pz + D) / denom

' If there is no positive t value, there's no
' intersection in this direction.
If t < 0.01 Then
    RayTraceable_FindT = -1
    Exit Function
End If

' Get the point of intersection with the plane.
X = px + t * Vx
Y = py + t * Vy
Z = pz + t * Vz

' Get the square vectors.
px = Point1.Trans(1)
py = Point1.Trans(2)
pz = Point1.Trans(3)
v1x = Point2.Trans(1) - px
v1y = Point2.Trans(2) - py 
v1z = Point2.Trans(3) - pz 
v2x = Point3.Trans(1) - px 
v2y = Point3.Trans(2) - py 
v2z = Point3.Trans(3) - pz 

' Get the i and j values for this point.
If (Abs(v1x) > 0.001) And _
    (Abs(v1y * v2x - v2y * v1x) > 0.001) _

 
< previous page page_613 next page >